package com.yunxi.service.localService.impl.otd;

import com.yunxi.core.service.ServiceImplPlus;
import com.yunxi.core.web.ApiResult;
import com.yunxi.core.web.ResponseUtil;
import com.yunxi.dao.otd.OtdProduceCalendarMapper;
import com.yunxi.model.otd.OtdProduceCalendar;
import com.yunxi.otd.pojo.OtdProduceCalendarWeekVO;
import com.yunxi.otd.pojo.OtdWeekColumnHeadVO;
import com.yunxi.service.localService.otd.OtdProduceCalendarService;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 生产工作日历 服务实现类
 * </p>
 *
 * @author XUQI
 * @since 2019-07-02
 */
@Service
public class OtdProduceCalendarServiceImpl extends
    ServiceImplPlus<OtdProduceCalendarMapper, OtdProduceCalendar> implements
    OtdProduceCalendarService {

    @Override
    public void updateIsWorkByDay(Date day, Integer isWork, String realName) {
        baseMapper.updateIsWorkByDay(day, isWork, realName);
    }

    @Override
    public List<Date> findWorkDay(Date startDate, Date endDate) {
        return baseMapper.selectWorkDay(startDate, endDate);
    }

    /**
     * 根据年月查询工作日
     * @param yearMonth 年月 201907
     * @return 日期集合
     */
    @Override
    public List<Date> findWorkDayByYearMonth(String yearMonth, String isWork) {
        return baseMapper.findWorkDayByYearMonth(yearMonth, isWork);
    }

    /**
     * 根据年周查询工作日
     *
     * @param year 年
     * @param week 周
     * @return 工作日
     */
    @Override
    public List<Date> findWorkDayByYearWeek(String year, String week) {
        return baseMapper.findWorkDayByYearWeek(year, week);
    }

    /**
     * 根据年月查询工作日日集合
     *
     * @param yearMonth 年月 201907
     * @return 日期集合
     */
    @Override
    public List<Integer> findWorkDayNumByYearMonth(String yearMonth) {
        return baseMapper.findIntWorkDayByYearMonth(yearMonth);
    }

    /**
     * 查询每月周数
     *
     * @param map 查询条件
     * @return List<List < OtdProduceCalendarVO>>
     */
    @Override
    public List<OtdProduceCalendarWeekVO> weekListByMap(Map<String, Object> map) {
        return baseMapper.findCalendarWeek(map);
    }

    /**
     * 查询某个月包含哪几周
     *
     * @param year 年
     * @param month 月
     * @return 周数集合
     */
    @Override
    public List<String> weekListByMonth(String year, String month) {
        return baseMapper.selectWeekListByMonth(year, month);
    }

    /**
     * 根据年周查询往后5周周数，包括查询周
     *
     * @param year 年
     * @param week 周
     * @return 周数集合
     */
    @Override
    public List<String> weekListByYearWeek(String year, String week) {
        return baseMapper.selectWeekListByYearWeek(year, week);
    }

    /**
     * 根据年月查询周数 格式：01(2019-01-01~2019-01-07)
     *
     * @param yearMonth 年月
     * @return List<List < OtdProduceCalendarVO>>
     */
    @Override
    public ApiResult weekColumnHead(String yearMonth) {
        return ResponseUtil.ok(baseMapper.selectWeekColumnHeadByMonth(yearMonth));
    }

    /**
     * 根据选定周查询5周列头 格式：01(2019-01-01~2019-01-07)
     *
     * @param year 年
     * @param week 周
     * @return ApiResult
     */
    @Override
    public ApiResult weekColumnHeadByWeek(String year, String week) {
        return ResponseUtil.ok(baseMapper.selectWeekColumnHeadByWeek(year, week));
    }
}